/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package singletonlogger;

import java.io.IOException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Achilleas
 */
public class User {
    
    private String username;
    private SingletonLogger sl;
    
    public User(String username) throws IOException{
       sl = SingletonLogger.getInstance(); 
       userSignedIn(username);
    
    }
    /**
     * @return the username
     */
    protected String getUsername() {
        return username;
    }

    /**
     * @param username the username to set
     */
    protected void setUsername(String username) {
        this.username = username;
    }
    
    
    public void userSignedIn(String username){
        System.out.println("User " + username + " signed in at + " + new Date().toString());
        try {
            sl.bufferedWriter.write("User " + username + " signed in at + " + new Date().toString());
            sl.bufferedWriter.newLine();
            sl.bufferedWriter.flush();
        } catch (IOException ex) {
            Logger.getLogger(SingletonLogger.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
   
}
